<?php
/*
 * Created on 28.09.2007 by Nikolai Plath
 *
 * * @file:debug.php
 */

/**
 * NiK DEBUG **
 * @DEBUG
 * 
 * ! set config file !
 */

class nikDebug
{
	var $active	= NULL;

	/**
	 * Debus a query
	 * @param str $query
	 * @param int $level - 1: output query
	 */
	function query( $query = '', $level = 0 )
	{
		global $database;
	
		if( ! $this->active ) return;

		if( $level == 1 ) echo '<pre class="debug">'.$query.'</pre>';
		if( $database->getErrorNum() ) echo $database->stderr();
	}//function
	
	/**
	 * @var $text string
	 * $text = "REQUEST"	- print out $_REQUEST vars
	 * $text = 'array'	- var_dump( $text )
	 * $text = 'other'	- prints out $text
	 * @param int $level
	 * @param str $titel
	 */
	function out( $text, $level = 0, $titel = NULL )
	{
	
		if( ! $this->active ) return;
	
		if( $titel )
		{
			echo'<div class="debug"><strong>'.$titel.'</strong></div>';
		} //if
		if( $level == 0 )
		{
			echo '<div class="debug">';
			if( is_array($text))
			{
				echo '<pre>';
				var_dump( $text );
				echo '</pre>';
			} elseif( is_object( $text ) )
			{
				echo '<pre>';
				print_r( $text );
				echo '</pre>';
			} else
			{
				switch ( $text )
				{
					case 'REQUEST':
						echo '<strong>REQUEST:</strong><br />';
						print_r( $_REQUEST );
					break;
					default:
						echo $text;
				}//switch
			}//if
			echo '</div>';
		}//if 
	}//function

}// class
?>
